﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Maticsoft.BLL;
using System.Text;
namespace Maticsoft.Web.Controls
{
    public partial class header : System.Web.UI.UserControl
    {
        public string headerMenuFlashTex = "";
        public string headerContentFlashText = "";
        public string serverPath = "";
        public string keyword = "请输入搜索内容";
        protected void Page_Load(object sender, EventArgs e)
        {   
                serverPath = Request.ServerVariables["SERVER_NAME"].ToString() + ":" + Request.ServerVariables["SERVER_PORT"].ToString();
                if ((Request.Params[PubConstant.MENU_PARM] != null) && (Request.Params[PubConstant.MENU_PARM].ToString() != ""))
                {
                    int menuId = int.Parse(Request.Params[PubConstant.MENU_PARM]);
                    dealGenerateHeader(menuId);
                }
                else {
                    dealGenerateHeader(0);
                }

                if ((Request.Params[PubConstant.PAGE_SEARCH] != null) && (Request.Params[PubConstant.PAGE_SEARCH].ToString() != ""))
                {
                    keyword = Request.Params[PubConstant.PAGE_SEARCH];
                }
           

        }
        public void dealGenerateHeader(int menuId)
        {

            PubConstant.MENU_INDEX menuIndex = PubConstant.MENU_INDEX.首页;
            try
            {
                menuIndex = (PubConstant.MENU_INDEX)Enum.ToObject(typeof(PubConstant.MENU_INDEX), menuId);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            string flashText = PubConstant.getMenuFlash()[menuIndex];

             //headerMenuFlashTex = createMenuFlashHtml(flashText);

             //headerContentFlashText = createContentFlashHtml(flashText);

            headerMenuFlashTex = flashText;

            headerContentFlashText = flashText;
            //switch (menuIndex)
            // {
            //     case PubConstant.MENU_INDEX.走进昌盛:
            //         {
            //             Console.WriteLine("走进昌盛");

            //             break;
            //         }
            //     case PubConstant.MENU_INDEX.新闻中心:
            //         {
            //              Console.WriteLine("新闻中心");
            //             break;
            //         }
            //     case PubConstant.MENU_INDEX.商务中心:
            //         {
            //             Console.WriteLine("商务中心");
            //             break;
            //         }
            //     case PubConstant.MENU_INDEX.人力资源:
            //         {
            //             Console.WriteLine("人力资源");
            //             break;
            //         }
            //     case PubConstant.MENU_INDEX.集团产业:
            //         {
            //             Console.WriteLine("集团产业");
            //             break;
            //         }
            //     case PubConstant.MENU_INDEX.互动留言:
            //         {
            //             Console.WriteLine("互动留言");
            //             break;
            //         }
            //     default:
            //         {
            //             Console.WriteLine("首页");
            //             break;
            //         }
            // }


        }

        public String createMenuFlashHtml(string flash) { 
             StringBuilder strFlash = new StringBuilder();
             strFlash.Append("AC_FL_RunContent('codebase',");
             strFlash.Append("''http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0',");
             strFlash.Append("'width','960',");
             strFlash.Append("'height','81',");
             strFlash.Append("'src','flash/header-menu/" + flash + "',");
             strFlash.Append("'quality','high','pluginspage',");
             strFlash.Append("'http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash',");
             strFlash.Append("'movie','flash/header-menu/" + flash + "'");
             strFlash.Append(");");
            //AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','960','height','81','src','flash/header-menu/menu_top_home','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','flash/header-menu/menu_top_home' ); //end AC code
             return strFlash.ToString();
 
        }

        public String createContentFlashHtml(string flash)
        {
            StringBuilder strFlash = new StringBuilder();
            strFlash.Append("AC_FL_RunContent('codebase',");
            strFlash.Append("''http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0',");
            strFlash.Append("'width','960',");
            strFlash.Append("'height','251',");
            strFlash.Append("'src','flash/header-content/" + flash + "',");
            strFlash.Append("'quality','high','pluginspage',");
            strFlash.Append("'http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash',");
            strFlash.Append("'movie','flash/header-content/" + flash + "'");
            strFlash.Append(");");
            //AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','960','height','251','src','flash/header-content/header','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','flash/header-content/header' ); //end AC code
            return strFlash.ToString();
        }
    }
}